import { createRouter, createWebHashHistory } from "vue-router"
import { useStore } from "vuex"

import { menuRoutes } from "./modules/menus"
import { adminRoutes } from "./modules/admin"
import { routerGuard } from "./guard"

const routes = [
    {
        path: "/",
        name: "/",
        redirect: "/home",
    },
    {
        path: "/login",
        name: "Login",
        component: () => import("@/views/login/index.vue"),
        meta: {
            auth: false,
            hide: true,
        },
    },
    {
        path: "/download",
        name: "Download",
        component: () => import("@/views/download/index.vue"),
        meta: {
            auth: false,
            hide: true,
        },
    },
    {
        path: "/403",
        name: "403",
        component: () => import("@/views/error/403.vue"),
    },
    {
        path: "/404",
        name: "404",
        component: () => import("@/views/error/404.vue"),
    },
    {
        path: "/500",
        name: "500",
        component: () => import("@/views/error/500.vue"),
    },
]

export const router = createRouter({
    history: createWebHashHistory(),
    routes: [...menuRoutes, ...routes, ...adminRoutes],
})

routerGuard(router)
